package com.sihai.ehr.web.action.share;

import com.sihai.core.LimitedList;
import com.sihai.core.beans.BeanInject;
import com.sihai.ehr.model.biz.Message;
import com.sihai.ehr.service.MessageService;
import com.sihai.ehr.web.action.EHRAction;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;


/**
 * author: wxn
 * since: 13-5-4 下午5:27
 */
@Results({
        @Result(name = "list", location = "message_list.jsp"),
        @Result(name = "input", location = "info_modify.jsp"),
        @Result(name = "relog", type = "redirectAction", params = { "actionName", "logout.xhtml" })
})
public class MessageAction extends EHRAction{
    @BeanInject
    private MessageService messageService;

    private LimitedList<Message> messages;

    @Action("/public/message-list")
    public String list()throws Exception{
        if(getCurrentUserId() == -1000){
            return "list";
        }
        messages = messageService.findByLoginUser(getCurrentUserId(), null, null);
        return "list";
    }

    public LimitedList<Message> getMessages() {
        return messages;
    }
}
